<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link rel="stylesheet" type="text/css" href="/css/editthings.css" />
	<link rel="stylesheet" type="text/css" href="/css/tabLanguages.css" />
	<script src="/js/admin/jquery/jquery-1.6.1.min.js" type="text/javascript"></script>
	<script type="text/javascript" src="/js/ckeditor/ckeditor.js" language="javascript" ></script>
	<link rel="stylesheet" type="text/css" href="/js/admin/jquery/ui/themes/ui-lightness/jquery.ui.all.css" />
	<script src="/js/admin/jquery/ui/jquery-ui-1.8.16.custom.min.js" type="text/javascript"></script>
	<script src="/js/admin/jquery/ui/external/jquery.bgiframe-2.1.2.js" type="text/javascript"></script>
	<script src="/js/admin/jquery/tab.js" type="text/javascript"></script>
	<script src="/js/admin/jquery/superfish/js/superfish.js" type="text/javascript"></script>
</head>
<body>
<?php if($this->error != 8){?>
<?php if($this->error == 1){?>
<script type="text/javascript">
	window.parent.$.prettyPhoto.close();
	window.top.location.reload();
	window.parent.$.prettyPhoto.close();
</script>
<?php } else {?>
<form method="post" action="/index/post?action=new" name="form_edit_product" id="form_edit_product">
	
	<div class="content_btn" style="float: right">
		<div class="submit">
			<input type="submit" value="<?php echo $this->Save;?>" name="submit" class="edit_submit"/>
		</div>
	</div>
	<div style="float:left;font-style: oblique;font-weight: bold;font-size: large;color:blue;"><?php echo $this->textTitle;?></div>
	<div style="clear: both;"></div>
	<hr></hr>
	<?php if($this->error == -1){?><h4 style="color:red"><?php echo $this->textError1;?></h4><?php }?>
	<?php if($this->error == 7){?><h4 style="color:red"><?php echo $this->textError7;?></h4><?php }?>					
	<table cellspacing="5" cellpadding="2">
		<tr>
			<td><span style="font-weight: bold;"><?php echo $this->textProductName;?></span></td>
			<td><input type="text" value="<?php echo $this->title;?>" size="30" maxlength="30" name="product_title" id="product_title" class="content_input"/></td>
		</tr>
		<?php if(isset($this->error_title) && $this->error_title == 1){?><tr ><td></td><td><span style="color:red;height: 10px;"><?php echo $this->textError2;?></span></td></tr><?php }?>
		<?php if(isset($this->cate)&&($this->cate!="")&&($this->cate!=0)&&($this->cate!=null)){?>
			<input name = "product_category" id = "product_category" value = "<?php echo $this->cate; ?>" type = "hidden" />
		<?php }else{?>
		<tr>
			<td><span style="font-weight: bold;"><?php echo $this->textCate;?></span></td>
			<td><select tabindex="0" name="product_category" id="product_category">
					<?php foreach ($this->CategoriesProduct as $category){?>
						<option <?php if(($this->category!=0)&&($this->category == $category["category_id"])){?>selected="selected"<?php } ?> value="<?php echo $category["category_id"];?>"><?php echo $category["category_name"];?></option>
					<?php } ?>
				</select></td>
		</tr>
		<?php if(isset($this->error_cate) && $this->error_cate == 1){?><tr><td></td><td><span style="color:red;height: 10px;"><?php echo $this->textError3;?></span></td></tr><?php }?>
		<?php }?>
		<tr>
			<td><span style="font-weight: bold;"><?php echo $this->Price;?></span></td>
			<td><input name="product_price" value = "<?php echo $this->price;?>" /></td>
		</tr>
		<?php if(isset($this->error_price) && $this->error_price == 1){?><tr><td></td><td><span style="color:red;height: 10px;"><?php echo $this->textError6;?></span></td></tr><?php }?>
		<tr>
			<td><span style="font-weight: bold;"><?php echo $this->textImage;?></span></td>
			<td>
				<img src="/images/noimage.jpg" id="image_url" class="image" style ="width:150px;height:150px;" onclick="image_upload('product_avatar', 'image_url','1');" />
				<input type="hidden" name="product_avatar" value="/images/noimage.jpg" id="product_avatar" />
			</td>
		</tr>
		<tr>
			<td><span style="font-weight: bold;"><?php echo $this->RelateImage;?></span></td>
			<td>
				<img src="/images/noimage.jpg" id="image_related_2" class="image" style ="width:80px;height:80px;" onclick="image_upload('image_related2', 'image_related_2','2');" />
				<input type="hidden" name="image_related[]" value="/images/noimage.jpg" id="image_related2" />
				<img src="/images/noimage.jpg" id="image_related_3" class="image" style ="width:80px;height:80px;" onclick="image_upload('image_related3', 'image_related_3','3');" />
				<input type="hidden" name="image_related[]" value="/images/noimage.jpg" id="image_related3" />			
				<img src="/images/noimage.jpg" id="image_related_4" class="image" style ="width:80px;height:80px;" onclick="image_upload('image_related4', 'image_related_4','4');" />
				<input type="hidden" name="image_related[]" value="/images/noimage.jpg" id="image_related4" />			
			</td>
		</tr>					
	</table>


<div id="content">
</div>

<hr />
        <div id="languages" class="htabs">
        	<a tab="#language0" class="selected"><?php echo 'Default'; ?></a>
          <?php foreach ($this->languages as $language) { ?>
          <a tab="#language<?php echo $language['language_id']; ?>"><?php echo $language['name']; ?></a>
		  <?php } ?>
        </div>
        <div id="language0">
			<div class="content_row">
				<div class="content_row_l"><p><?php echo $this->ShortDes;?></p></div>
				<?php if(isset($this->error_desc['Default'][1])){?><h4 style="color:red;margin-top: -15px;height: 10px;"><?php echo $this->error_desc['Default'][1];?></h4><?php }?>
					<div class="content_row_r">
						<textarea name="product_short_description[Default]" style="width:500px"><?php echo $this->short_des['Default'];?></textarea>

					</div>

			</div>
			<div class="content_row">
				<div class="content_row_l"><p><?php echo $this->Productinfo?></p></div>
				<?php if(isset($this->error_desc['Default'][0])){?><h4 style="color:red;margin-top: -15px;height: 10px;"><?php echo $this->error_desc['Default'][0];?></h4><?php }?>
					<div class="content_row_r">
						<textarea name="product_description[Default]" class="ckeditor" style="visibility: hidden; display: none;"><?php echo $this->description['Default'];?></textarea>
					</div>
			</div>
		</div>        
        <?php foreach ($this->languages as $language) { ?>
        <div id="language<?php echo $language['language_id']; ?>">
			<div class="content_row">
				<div class="content_row_l"><p><?php echo $this->ShortDes;?></p></div>
				<?php if(isset($this->error_desc[$language['name']][1])){?><h4 style="color:red;margin-top: -15px;height: 10px;"><?php echo $this->error_desc[$language['name']][1];?></h4><?php }?>
					<div class="content_row_r">
						<textarea name="product_short_description[<?php echo $language['name'];?>]" style="width:500px"><?php echo $this->short_des[$language['name']];?></textarea>
					</div>
			</div>
			<div class="content_row">
				<div class="content_row_l"><p><?php echo $this->Productinfo?></p></div>
				<?php if(isset($this->error_desc[$language['name']][0])){?><h4 style="color:red;margin-top: -15px;height: 10px;"><?php echo $this->error_desc[$language['name']][0];?></h4><?php }?>
					<div class="content_row_r">
						<textarea name="product_description[<?php echo $language['name'];?>]" class="ckeditor" style="visibility: hidden; display: none;"><?php echo $this->description[$language['name']];?></textarea>
					</div>
			</div>
		</div>
		<?php }?>
</form>
<script type="text/javascript"><!--
	function image_upload(field, preview, id) {
	$('#dialog').remove();
	$('#content').prepend('<div id="dialog" style="padding: 3px 0px 0px 0px;"><iframe src="/admin/filemanager?field=' + encodeURIComponent(field) + '" style="padding:0; margin: 0; display: block; width: 100%; height: 100%;" frameborder="no" scrolling="auto"></iframe></div>');
	$('#dialog').dialog({

							title: 'Images Manager',
							close: function (event, ui) {
								if ($('#' + field).attr('value')) {
									$('#' + preview).replaceWith('<img src="' +$('#' + field).attr('value') + '" alt="" id="' + preview + '" class="image" style="width:80px;height:80px" onclick="image_upload(\'' + field + '\', \'' + preview + '\', \'' + id + '\');" />');

								}
							},	
							bgiframe: false,
							width: 700,
							height: 400,
							resizable: false,
							modal: false
						});
					};

//--></script>		
<script type="text/javascript"><!--
$.tabs('#languages a'); 
//--></script>		
<?php }?>
<?php } else {echo $this->textError8;}?>

</body>		
</html>		